using System;
using Castle.MonoRail.ActiveRecordSupport;
using Castle.MonoRail.Framework;
using IronMis2.Models;


namespace IronMis2.Controllers
{
    public class StoreHouseController:BaseController
    {
        public void Index()
        {
            PropertyBag["storehouses"] = Storehouse.FindAll();
        }
        public void Edit(Guid id)
        {
            PropertyBag["storehouse"] = Storehouse.Find(id);
            PropertyBag["employees"] = Employee.FindAll();
        }
        public void Update([DataBind("storehouse")] Storehouse storehouse)
        {
            storehouse.UpdateAndFlush();
            RedirectToAction("Index");
        }
        public void Destory(Guid id)
        {
            Storehouse.Find(id).DeleteAndFlush();
            RedirectToAction("Index");
        }
        public void Create()
        {
            PropertyBag["employees"] = Employee.FindAll();
        }
        public void Add([DataBind("storehouse")] Storehouse storehouse)
        {
            storehouse.CreateAndFlush();
            RedirectToAction("Index");
        }
    }
}
